package com.lwx.fileDemo;

import java.io.File;

public class fileDemo1 {
    public static void main(String[] args) {
        travelFiles("D:\\BaiduNetdiskDownload\\94_电商：使用Nginx实现负载均衡及整体环境部署【尚学堂.百战程序员】","--");
    }

    //遍历路径为path的文件夹，并且分割符为seperator
    public static void travelFiles(String path,String seperator){
        File file = new File(path);
        File[] chiledrenFiles = file.listFiles();
        for (File childFile: chiledrenFiles ) {
            travelFiles(childFile, seperator);
        }
    }

    private static void travelFiles(File file,String seperator){
        if(file.isFile()){
            if("nginx安装手册.doc".equals(file.getName())){
                System.out.println(file.getParentFile().getName());
            }
//            System.out.println(seperator + file.getName());
            return;
        }
//        System.out.println(seperator + file.getName());
        seperator += "--";
        File[] files = file.listFiles();
        for (File child: files ) {
            travelFiles(child,seperator);
        }
    }
}
